package org.liulinlin.sejw.db;

import java.sql.*;

public class Goods { //extends DataAccessServiceImpl {
	private String id;
	private String name;
	private double weight;
	private double size;
	private GoodsNum goodsNum;
	private double value;
	private String pack;
	private String type;
	private double temp;
	private String tempUnit;
	private String dangerClass;
	private String dangerProperty;
	private String uNID;
	
	public Goods() {
		
	}
	public Goods(String id) {
		DBConnectionManager connMgr = DBConnectionManager.getInstance();
		Connection con = connMgr.getConnection("shipping_export");
		if (con == null) {
			System.out.println("不能获得数据库连接");
			return;
		}
		
		try {
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery("select * from Goods where Goods_ID = '" + id + "'");
		
			rs.next();
			this.id = id;
			name = rs.getString("Goods_Name");
			weight = rs.getDouble("Goods_Weight");
			size = rs.getDouble("Goods_Size");
			goodsNum = new GoodsNum(rs.getString("GN_ID"));
			value = rs.getDouble("Goods_Value");
			pack = rs.getString("Goods_Pack");
			type = rs.getString("Goods_Type");
			temp = rs.getDouble("Goods_Temp");
			tempUnit = rs.getString("Goods_TempUnit");
			dangerClass = rs.getString("Goods_DangerClass");
			dangerProperty = rs.getString("Goods_DangerProperty");
			uNID = rs.getString("Goods_UNID");
			
			rs.close();
			stmt.close();
		} catch(SQLException e) {
			e.printStackTrace();
		}
		
		connMgr.freeConnection("shipping_export", con);
		connMgr.release();
	}
	
	public void setId(String id) {
		this.id = id;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setWeight(double weight) {
		this.weight = weight;
	}
	public void setSize(double size) {
		this.size = size;
	}
	public void setGoodsNum(GoodsNum goodsNum) {
		this.goodsNum = goodsNum;
	}
	public void setValue(double value) {
		this.value = value;
	}
	public void setPack(String pack) {
		this.pack = pack;
	}
	public void setType(String type) {
		this.type = type;
	}
	public void setTemp(double temp) {
		this.temp = temp;
	}
	public void setTempUnit(String tempUnit) {
		this.tempUnit = tempUnit;
	}
	public void setDangerClass(String dangerClass) {
		this.dangerClass = dangerClass;
	}
	public void setDangerProperty(String dangerProperty) {
		this.dangerProperty = dangerProperty;
	}
	public void setUNID(String uNID) {
		this.uNID = uNID;
	}
	
	public String getId() {
		return id;
	}
	public String getName() {
		return name;
	}
	public double getWeight() {
		return weight;
	}
	public double getSize() {
		return size;
	}
	public GoodsNum getGoodsNum() {
		return goodsNum;
	}
	public double getValue() {
		return value;
	}
	public String getPack() {
		return pack;
	}
	public String getType() {
		return type;
	}
	public double getTemp() {
		return temp;
	}
	public String getTempUnit() {
		return tempUnit;
	}
	public String getDangerClass() {
		return dangerClass;
	}
	public String getDangerProperty() {
		return dangerProperty;
	}
	public String getUNID() {
		return uNID;
	}
}
